<?php
namespace app\mobile\controller;

use app\model\Util; 
use app\model\Theme; 
use app\model\Worker; 

class Myorder extends Base
{
    public function Myorder()
    {
global $_G, $_P;
$op = !empty($_P['op']) ? $_P['op'] : 'display';
$system=$_G['system'];
$fans = $this->checkuser();
$themeid = intval($_P['themeid']);
if($themeid < 0){
	return_msg('活动入口不正确');
}
$recordid = intval($_P['recordid']);
$theme = Theme::getThemeById($themeid);
if(empty($theme['id'])){
    die(Util::showError("请确认活动地址是否正确"));
    return;
}

$config = 	Theme::getConfig($themeid);

$result = Worker::Myorder($system,$theme,$config,$fans,$themeid);

if ($result['error']==1) {
    die(Util::showError($result['msg']));
    return;
}else{
    $result['jubf']['title'] = empty($theme['jubf'])?'':$theme['jubf'].'-';
    $result['jubf']['banquan'] = !empty($theme['USERCOMPANYNAME'])?$theme['USERCOMPANYNAME']:$_G['companyname'];
    $result['jishu'] = Worker::getjishu($theme,$system);
}
$url = $this->createMobileUrl("myorder",array('themeid'=>$themeid)) . "&soft=" . $theme['softkey'];

if ($result['hexiao']['tishi']==1) {
    return_msg($result['hexiao']['msg'],$url,'success') ;
}elseif ($result['hexiao']['tishi']==2) {
    return_msg($result['hexiao']['msg'],$url,'warning') ;
}
$return_clicent = get_defined_vars();
return view('/base/hexiao', $return_clicent);	
}
}